﻿<%@ Page Title="" Language="C#" MasterPageFile="~/NestedMasterPage.master" EnableEventValidation="false" %>

<%@ Register TagPrefix="Page" TagName="Nav" Src="~/UserControls/PageControlOrder.ascx" %>

<%@ Import Namespace="System.Web.Script.Serialization" %>

<script runat="server"> 

  protected void Page_Load(object sender, EventArgs e)
  {
    if (Page.IsPostBack == false)
    {
      txtBuyerZIP.Attributes.Add("ReadOnly", "ReadOnly");
      SetLoginInfo();
      if (HF_AuthType.Value == "1")
      {
        //會員樂e購帳戶資料
        MemberGetAccount();
      }
      else if (HF_AuthType.Value == "2")
      {
        //企業會員樂e購帳戶資料

      }
      else if (HF_AuthType.Value == "3")
      {
        //非會員樂e購帳戶資料
        NonMemberGetAccount();
      }
    }
  }

  protected void SetLoginInfo()
  {
    //判斷是否已會員登入
    if (!string.IsNullOrEmpty(HttpContext.Current.User.Identity.Name))
    {
      HF_AuthType.Value = "1"; // 預設是會員登入
      HF_UserID.Value = HttpContext.Current.User.Identity.Name;
      if (HttpContext.Current.Request.Cookies["LoginInfo"] != null)
      {
        HttpCookie LoginInfo = HttpContext.Current.Request.Cookies["LoginInfo"] as HttpCookie;
        HF_AuthType.Value = LoginInfo.Values["AuthType"].ToString();
      }
    }
    else
    {
      HF_AuthType.Value = "3"; // 非會員登入
    }
    //測試資料
    //strUserID = "1300038423";
    //strAuthType = "1";
  }

  //會員資料
  protected void MemberGetAccount()
  {
    //判斷是否已會員登入
    if (!string.IsNullOrEmpty(HttpContext.Current.User.Identity.Name))
    {
      //產生清單
      GetOrderList(HF_UserID.Value, HF_AuthType.Value);
      //E-CouponE-Coupon
      GetECouponList(HF_UserID.Value, HF_AuthType.Value);
      //會員個人資料
      GetMemberData(HF_UserID.Value, HF_AuthType.Value);
    }
  }

  //非會員資料
  protected void NonMemberGetAccount()
  {
    //判斷是否已登入
    if (!string.IsNullOrEmpty(HttpContext.Current.User.Identity.Name))
    {
      //E-CouponE-Coupon
      GetECouponList(HF_UserID.Value, HF_AuthType.Value);
    }
  }

  private void GetOrderList(string UserID, string authType)
  {
    //會員卡號
    string strMemberid = UserID;
    string strAuthType = authType;
    //查詢日期條件
    string strFromDate = "";
    string strToDate = "";
    int intOrderPeriod = Convert.ToInt16(rbtnlOrderDate.SelectedValue);
    if (intOrderPeriod != 0)
    {
      strToDate = DateTime.Now.ToString("yyyy/MM/dd").Replace("/", "");
      strFromDate = DateTime.Now.AddMonths(-intOrderPeriod).ToString("yyyy/MM/dd").Replace("/", "");
    }
    //分頁     
    string ListCount = "10";
    int PageNumber = this.Nav1.currentPageNumber;
    int StartNumber = 1 + Convert.ToInt32(ListCount) * (PageNumber - 1);
    int EndNumber = StartNumber + Convert.ToInt32(ListCount) - 1;

    B2C_MALL_ACCOUNT ws = new B2C_MALL_ACCOUNT();
    ws.Url = ConfigurationManager.AppSettings["B2C_MALL_ACCOUNT"].ToString();
    string jsonString = ws.B2C_MALL_GetOrderList(CommonUtil.GetWebDevice()
      , strMemberid, strAuthType, strFromDate, strToDate, StartNumber.ToString(), EndNumber.ToString());
    JObject restoredObject = JsonConvert.DeserializeObject<JObject>(jsonString);
    string Is_Valid = restoredObject["Is_Valid"].ToString();
    string msg = restoredObject["Msg"].ToString();

    if (Is_Valid == "Y")
    {
      dynamic dynObj = restoredObject["OrderList_Chk_List"];
      this.gvOrderList.DataSource = dynObj;
      this.gvOrderList.DataBind();
      this.Nav1.TotalCount = this.Nav2.TotalCount = restoredObject["Total_Count"].ToString();
      this.Nav1.PagesCount = this.Nav2.PagesCount =
          Math.Ceiling((Convert.ToDecimal(restoredObject["Total_Count"]) / Convert.ToDecimal(ListCount))).ToString();
    }
    else
    {
      this.gvOrderList.DataSource = null;
      this.gvOrderList.DataBind();
      this.Nav1.TotalCount = this.Nav2.TotalCount = "0";
      this.Nav1.PagesCount = this.Nav2.PagesCount = "0";
    }
    //不滿5頁的去除其頁數
    this.Nav1.DisplayPageNumber();
    this.Nav2.DisplayPageNumber();
  }

  protected void Nav1_OnPageSelected(object sender)
  {
    if (sender == this.Nav1)
    {
      this.Nav2.currentPageNumber = this.Nav1.currentPageNumber;
    }
    else
    {
      this.Nav1.currentPageNumber = this.Nav2.currentPageNumber;
    }
    //取得欲檢視頁面號碼並產生產品清單 
    if (HF_UserID.Value != "" && HF_AuthType.Value != "")
    {
      GetOrderList(HF_UserID.Value, HF_AuthType.Value);
    }
  }

  private void GetECouponList(string UserID, string authType)
  {
    //會員卡號及非會員身份證
    string strMemberid = UserID;
    string strAuthType = authType;
    B2C_MALL_ACCOUNT ws = new B2C_MALL_ACCOUNT();
    ws.Url = ConfigurationManager.AppSettings["B2C_MALL_ACCOUNT"].ToString();
    string jsonString;
    if (authType == "1")
    {
      jsonString = ws.B2C_MALL_GetCouponList_Mbr(CommonUtil.GetWebDevice(), strMemberid, strAuthType, strMemberid);
    }
    else
    {
      jsonString = ws.B2C_MALL_GetCouponList_NonMbr(CommonUtil.GetWebDevice(), strMemberid, strAuthType, strMemberid);
    }
    JObject restoredObject = JsonConvert.DeserializeObject<JObject>(jsonString);
    string Is_Valid = restoredObject["Is_Valid"].ToString();
    string msg = restoredObject["Msg"].ToString();
    if (Is_Valid == "Y")
    {
      dynamic dynObj = restoredObject["pDiscounts_Ary_List"];
      this.gvECouponList.DataSource = dynObj;
      this.gvECouponList.DataBind();
    }
  }

  //會員個人資料
  private void GetMemberData(string UserID, string strAuthType)
  {
    if (strAuthType == "1")
    {
      B2C_MALL_ACCOUNT ws = new B2C_MALL_ACCOUNT();
      ws.Url = ConfigurationManager.AppSettings["B2C_MALL_ACCOUNT"].ToString();
      string jsonString;
      jsonString = ws.B2C_MALL_GetMemberData(CommonUtil.GetWebDevice(), UserID);
      JObject restoredObject = JsonConvert.DeserializeObject<JObject>(jsonString);
      string Is_Valid = restoredObject["Is_Valid"].ToString();
      string msg = restoredObject["Msg"].ToString();
      if (Is_Valid == "Y")
      {
        lblCARD_ID.Text = restoredObject["F_CARD_ID"].ToString();
        lblMemberName.Text = restoredObject["F_CHT_NAME"].ToString();
        tbTEL_HOME.Text = restoredObject["F_TEL_HOME"].ToString();
        tbMOBILE.Text = restoredObject["F_MOBILE"].ToString();
        tbTEL_OFFICE.Text = restoredObject["F_TEL_OFFICE"].ToString();
        tbFAX.Text = restoredObject["F_FAX"].ToString();
        tbEMAIL.Text = restoredObject["F_EMAIL"].ToString();
        ddlBuyerZone1.SelectedValue = restoredObject["CITY"].ToString();
        hfBuyerZone1.Value = restoredObject["CITY"].ToString();
        ddlBuyerZone2.SelectedValue = restoredObject["TOWNS"].ToString();
        hfBuyerZone2.Value = restoredObject["TOWNS"].ToString();
        txtBuyerZIP.Text = restoredObject["F_ZIP"].ToString();
        hfBuyerZIP.Value = restoredObject["F_ZIP"].ToString();
        txtBuyerAddress.Text = restoredObject["F_ADDR1"].ToString();
      }
    }

  }

  //訂單查詢
  protected void lbtnSearch_Click(object sender, EventArgs e)
  {
    SetLoginInfo();
    if (HF_UserID.Value != "" && HF_AuthType.Value != "")
    {
      GetOrderList(HF_UserID.Value, HF_AuthType.Value);
    }
  }

  protected void btnUpdateMemberData_Click(object sender, EventArgs e)
  {
    B2C_MALL_ACCOUNT ws = new B2C_MALL_ACCOUNT();
    ws.Url = ConfigurationManager.AppSettings["B2C_MALL_ACCOUNT"].ToString();
    string jsonString;
    jsonString = ws.B2C_MALL_Update_MemberData(CommonUtil.GetWebDevice(), lblCARD_ID.Text, tbTEL_HOME.Text.Trim(), tbTEL_OFFICE.Text.Trim(), tbMOBILE.Text.Trim(), tbFAX.Text.Trim(), tbEMAIL.Text.Trim(), txtBuyerAddress.Text.Trim(), txtBuyerZIP.Text.Trim());
    JObject restoredObject = JsonConvert.DeserializeObject<JObject>(jsonString);
    string Is_Valid = restoredObject["Is_Valid"].ToString();
    string msg = restoredObject["Msg"].ToString();
  }

  //protected void gvOrderList_RowDataBound(object sender, GridViewRowEventArgs e)
  //{
  //  if (e.Row.RowType == DataControlRowType.DataRow)
  //  {
  //    Label lbl_ORDER_STATUS = e.Row.FindControl("lbl_ORDER_STATUS") as Label;
  //    lbl_ORDER_STATUS.Text = CommonUtil.GetOrderStatus(lbl_ORDER_STATUS.Text);
  //  }
  //}
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="NestedContent" runat="server">
  <script type="text/javascript">

    var authType = "";

    $(document).ready(function () {
      authType = $("#HF_AuthType").val();
      var UserID = $("#HF_UserID").val();
      var OrderID = "";//訂單編號
      var CustName = "";//訂購人姓名
      var ActiveTab = "<%= Server.HtmlEncode(Request["ActiveTab"].ToString()) %>";
          if ($.cookie("jqc_AuthType") != undefined) {
            authType = $.cookie("jqc_AuthType");
          }
          if ($.cookie("AccOrderID") != undefined) {
            OrderID = $.cookie("AccOrderID");
          }

          if ($.cookie("AccCustName") != undefined) {
            CustName = $.cookie("AccCustName");
          }
          if (authType.length == 0) {
            window.location.href = "<%= Page.ResolveUrl("~/Home.aspx")%>"
            }
            else if (authType == "2")//企業會員
            {
              //取得訂單明細資料
              GetAccountOrderDetails(OrderID, CustName);
              $("[id*='liECoupon']").hide();
              $("[id*='liMile']").hide();
              $("[id*='liPerInfo']").hide();
            }
            else if (authType == "3")//非會員
            {
              $("[id*='liMile']").hide();
              $("[id*='liPerInfo']").hide();
              if (ActiveTab == "2") {
                $("[id*='liOrders']").hide();
                $('.tab-content', $('.tab-areas')).eq(1).show();
                $("[id*='aECoupon']").addClass('active');
                $("[id*='OrderList']").hide();
                $("[id*='OrderDetails']").hide();
              }
              else {
                //取得訂單明細資料
                GetAccountOrderDetails(OrderID, CustName);
                if (ActiveTab == "1") {
                  $("[id*='liECoupon']").hide();
                  //if (UserID == "") { $("[id*='liECoupon']").hide(); 
                }
              }
            }
      $.removeCookie('jqc_AuthType', { path: "/" });
    });

          //取得訂單明細
          function GetAccountOrderDetails(OrderID, CustName) {
            $.ajax({
              type: "POST",
              url: "<%= Page.ResolveUrl("~/Accounts/GetOrderDetail.aspx/GetOrderDetail")%>",
              data: "{'OrderID': '" + OrderID + "','BuyerName':'" + CustName + "'}",
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              success: function (data, status) {
                if (data.d != '-1') {
                  var result = JSON.parse(data.d); //取得回傳的Json資料
                  var Is_Valid = result.Is_Valid; //取得Json第一個值 Is_Valid
                  var Msg = result.Msg; //取得Json第二個值 Msg
                  if (Is_Valid == "Y") {
                    $("[id*='lblORDER_NO']").text(OrderID);//訂單編號
                    var odate = result.ORDER_DATE;//訂購日期
                    $("[id*='lblORDER_DATE']").text(odate.substr(0, 4) + "/" + odate.substr(4, 2) + "/" + odate.substr(6, 2));//訂購日期
                    $("[id*='lblPAY_TYPE']").text(result.PAY_TYPE);//付款方式
                    $("[id*='lblORDER_STATUS']").text(result.ORDER_STATUS);//訂單狀況
                    $("[id*='lblRCVR_Name']").text(result.RCVR_Name);//收件人姓名
                    $("[id*='lblRCVR_TEL_H']").text(result.RCVR_TEL_H);//收件人電話
                    $("[id*='lblRCVR_ZIP_CODE_RCVR_ADDRESS']").text(result.RCVR_ZIP_CODE_RCVR_ADDRESS);//收件人地址
                    $("[id*='lblCUST_NAME']").text(result.CUST_NAME);//購買者姓名
                    $("[id*='lblCUST_ZIP_CODE_CUST_ADDRESS']").text(result.CUST_ZIP_CODE_CUST_ADDRESS);//購買者地址
                    $("[id*='lblCUST_TEL_H']").text(result.CUST_TEL_H);//購買者電話
                    var INVOICE = "否";
                    if (result.INVOICE_PRINT_IND == "Y") { INVOICE = "是"; }
                    $("[id*='lblINVOICE_PRINT_IND']").text(INVOICE);//是否列印紙本電子發票(電子發票證明聯)
                    var pItemList_Ary = result.pItemList_Ary_List;
                    $("[id*='div1']").text('');//清空購物清單
                    var orderList = "";
                    var num;
                    var re = /(-?\d+)(\d{3})/;
                    orderList += '<table>';
                    orderList += '<caption>';
                    orderList += '<span class="fl">購物清單</span> <span class="red-text fr">總價 ' + numeral(result.RCV_AMT).format('$ 0,0[.]00') + ' 元</span>';
                    orderList += '</caption>';
                    orderList += '<tr>';
                    orderList += '<th class="spacer"></th>';
                    orderList += '<th>NO</th>';
                    orderList += '<th>商品圖</th>';
                    orderList += '<th class="insize1">商品名稱</th>';
                    orderList += '<th>單價</th>';
                    orderList += '<th>數量</th>';
                    orderList += '<th>扣抵哩程</th>';
                    //orderList += '<th>折扣</th>';
                    orderList += '<th>規格</th>';
                    orderList += '<th>小計</th>';
                    orderList += '<th class="spacer"></th>';
                    orderList += '</tr>';
                    $.each(result.pItemList_Ary_List, function (i) {
                      //$.each(result.pItemList_Ary_List[i], function (key, val) {
                      //    alert(j + key + val);                                
                      //})
                      orderList += '<tr class="no-border">';
                      orderList += '<td class="spacer"></td>';
                      orderList += '<td>' + (i + 1) + '</td>';//編號
                      orderList += '<td><img class="size1" alt="' + result.pItemList_Ary_List[i]["SMAS_CODE_NAME"] + '" src="' + result.pItemList_Ary_List[i]["B2C_IMAGE_PATH"] + '" /></td>';//商品圖
                      orderList += '<td><p>' + result.pItemList_Ary_List[i]["SMAS_CODE_NAME"] + '</p></td>';//商品名稱
                      orderList += '<td>' + numeral(result.pItemList_Ary_List[i]["UNIT_PRICE"]).format('$ 0,0[.]00') + '</td>';//單價
                      orderList += '<td>' + result.pItemList_Ary_List[i]["ORDER_QTY"] + '</td>';//數量
                      orderList += '<td>' + result.pItemList_Ary_List[i]["UNIT_MILEAGE"] + '</td>';//扣抵哩程
                      //orderList += '<td>' + result.pItemList_Ary_List[i]["DISC"] + '</td>';//折扣 不秀此欄位 by Adams待與Allen討論
                      orderList += '<td>' + result.pItemList_Ary_List[i]["PRODUCT_SPEC_TXT"] + '</td>';//規格
                      num = result.pItemList_Ary_List[i]["SUB_TOTAL"] + "";
                      while (re.test(num)) {
                        num = num.replace(re, "$1,$2")
                      }
                      orderList += '<td>$' + num + '</td>';//小計
                      orderList += '</tr>';
                    });
                    orderList += '</table>';
                    $("[id*='div1']").append(orderList);//加入購物清單到div

                    $("[id*='lblSUB_TOTAL_SUM']").text(numeral(result.SUB_TOTAL_SUM).format('$ 0,0[.]00'));//單價總計
                    $("[id*='lblDISCOUNT_AMT']").text(numeral(result.DISCOUNT_AMT).format('$ 0,0[.]00'));//折扣金額
                    //$("[id*='lblTTL_AMT']").text(result.TTL_AMT);// 總價
                    $("[id*='lblCOUPON_AMT']").text(numeral(result.COUPON_AMT).format('$ 0,0[.]00'));//e-Coupon金額
                    $("[id*='lblFREIGHT_CHARAGE']").text(numeral(result.FREIGHT_CHARAGE).format('$ 0,0[.]00'));//運費
                    $("[id*='lblMILEAGE']").text(result.MILEAGE);//哩程總計
                    $("[id*='lblRCV_AMT']").text(numeral(result.RCV_AMT).format('$ 0,0[.]00'));//消費總計
                    SetOrderListVisible(0);
                  }
                  else {
                    if (authType == "1") { SetOrderListVisible(1); }
                    else { SetOrderListVisible(0); }
                    alert(Msg);
                  }
                }
                else {
                  if (authType == "1") { SetOrderListVisible(1); }
                  else { SetOrderListVisible(0); }
                  alert("查無訂單詳細資料!");
                }
              },
              error: function (xhr, ajaxOptions, thrownError) {
                if (authType == "1") { SetOrderListVisible(1); }
                else { SetOrderListVisible(0); }
                alert(JSON.stringify(xhr));
              }
            });
          }

          //設定訂單及訂單詳細資料的顯示
          function SetOrderListVisible(b) {
            $("[id*='OrderList']").hide();//隠藏訂單List
            $("[id*='OrderDetails']").hide();//隠藏訂單詳細資料
            if (b == 1) { $("[id*='OrderList']").show(); } //顯示訂單List
            else { $("[id*='OrderDetails']").show(); }//顯示訂單詳細資料

            $('.JS-tabs ul li a').click(function () {
              $("[id*='OrderDetails']").hide();
              if ($(this).attr('id') == "aOrders" && (authType == "2" || authType == "3")) {
                $("[id*='OrderList']").hide();
                $("[id*='OrderDetails']").show();
              }
            });
          }


          //郵遞區號
          $(document).ready(function () {
            InitAddress();
          });

          //郵遞區號初始化
          function InitAddress() {
            //取得縣市選項
            $('#<%= ddlBuyerZone1.ClientID %>').append($("<option></option>").attr("value", "").text(" - 縣市 - "));
              $('#<%= ddlBuyerZone2.ClientID %>').append($("<option></option>").attr("value", "").text(" - 鄉鎮市 - "));
              for (var i in zip[0]) {
                $('#<%= ddlBuyerZone1.ClientID %>').append($("<option></option>").attr("value", zip[0][i]).text(zip[0][i]));
                }

              //鄉鎮市
                $('#<%= ddlBuyerZone1.ClientID %>').change(function () {
                //清除Zone2與ZipCode
                //$('#<%= txtBuyerZIP.ClientID %>').val("");
                  $('#<%= ddlBuyerZone2.ClientID %> option').remove();
                  $('#<%= ddlBuyerZone2.ClientID %>').append($("<option></option>").attr("value", "").text(" - 鄉鎮市 - "));
                  if (this.selectedIndex > 0) {
                    for (var i in zip[this.value]) {
                      $('#<%= ddlBuyerZone2.ClientID %>').append($("<option></option>").attr("value", i).text(i));
                    }
                  }
                });

              //郵遞區號
                $('#<%= ddlBuyerZone2.ClientID %>').change(function () {
                if (this.selectedIndex > 0) {
                  $('#<%= txtBuyerZIP.ClientID %>').val(zip[$('#<%= ddlBuyerZone1.ClientID %>').find(":selected").val()][$('#<%= ddlBuyerZone2.ClientID %>').find(":selected").val()]);
                      //紀錄所選Zone1,Zone2
                      $('#<%= hfBuyerZone1.ClientID %>').val($('#<%= ddlBuyerZone1.ClientID %>').find(":selected").val());
                      $('#<%= hfBuyerZone2.ClientID %>').val($('#<%= ddlBuyerZone2.ClientID %>').find(":selected").val());
                    }
                });

              //由Zip取得Zone1,Zone2
                  if ($('#<%= txtBuyerZIP.ClientID %>').val().length > 0) {
                $('#<%= ddlBuyerZone1.ClientID %>').val($('#<%= hfBuyerZone1.ClientID %>').val());
                  $('#<%= ddlBuyerZone1.ClientID %>').change();
                  $('#<%= ddlBuyerZone2.ClientID %>').val($('#<%= hfBuyerZone2.ClientID %>').val());
                  $('#<%= ddlBuyerZone2.ClientID %>').change();
                }

              }


              //會員資料修改
              function UpdateMemberData() {
                $.ajax({
                  type: "POST",
                  url: "<%= Page.ResolveUrl("~/Accounts/UpdateMemberData.aspx/UpdateMemberData")%>",
              data: "{'CARD_ID': '" + $('#<%= lblCARD_ID.ClientID %>').text()
                   + "','TEL_HOME': '" + $('#<%= tbTEL_HOME.ClientID %>').val()
                     + "','TEL_OFFICE':'" + $('#<%= tbTEL_OFFICE.ClientID %>').val()
                     + "','MOBILE':'" + $('#<%= tbMOBILE.ClientID %>').val()
                     + "','FAX':'" + $('#<%= tbFAX.ClientID %>').val()
                     + "','EMAIL':'" + $('#<%= tbEMAIL.ClientID %>').val()
                     + "','Address':'" + $('#<%= txtBuyerAddress.ClientID %>').val()
                     + "','ZIP':'" + $('#<%= txtBuyerZIP.ClientID %>').val() + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data, status) {
              if (data.d != '-1') {
                var result = JSON.parse(data.d); //取得回傳的Json資料
                var Is_Valid = result.Is_Valid; //取得Json第一個值 Is_Valid
                var Msg = result.Msg; //取得Json第二個值 Msg
                if (Is_Valid == "Y") {
                  alert("資料更新成功!");
                }
                else {
                  alert(Msg);
                }
              }
              else {
                alert("資料更新失敗!");
              }
            },
            error: function (xhr, ajaxOptions, thrownError) {
              alert(JSON.stringify(xhr));
            }
          });
          }

  </script>
  <script src="../Scripts/address.js"></script>
  <style>
    @media print {
      .myDivToPrint {
        background-color: white;
        height: 100%;
        width: 960px;
        position: fixed;
        top: 0;
        left: 0;
        margin: 0;
        padding: 15px;
        font-size: 14px;
        line-height: 18px;
      }
      .header, .footer, .left-side, .simple-banner, .plus-products , .inner ,.breadcrumbs  {
        display: none;
      }
      .product-spec .tab-areas {
        display: none;
      }
      .product-spec .tab-bar {
        display: none;
      }
    }
  </style>
  <div class="breadcrumbs  dotted">
    <a href="../Home.aspx">首頁</a> / <a href="#" class="current">我的樂e購帳戶</a>
  </div>
  <div class="inner">
    <h1>我的樂e購帳戶</h1>
  </div>
  <div class="product-spec">
    <div class="tab-bar JS-tabs">
      <ul>
        <li id="liOrders">
          <a id="aOrders" href="#" class="active" onclick="SetOrderListVisible(1);">訂單查詢</a>
        </li>
        <li id="liECoupon">
          <a id="aECoupon" href="#">E-Coupon</a>
        </li>
        <li id="liMile">
          <a id="aMile" href="#" class="OutlinkBox" onclick="OutlinkBox('https://eservice.evaair.com/Evaweb/EVA/FFP/login.aspx?lang=zh-tw');">哩程查詢</a>
        </li>
        <li id="liPerInfo">
          <a id="aPerInfo" href="#">個人資料</a>
        </li>
      </ul>
    </div>
    <div class="tab-areas">
      <div id="OrderList">
        <div class="tab-content">
          <div class="selection">
            <h2>請選擇訂購區間</h2>
            <table>
              <tr>
                <td>
                  <asp:RadioButtonList ID="rbtnlOrderDate" runat="server" RepeatDirection="Horizontal">
                    <asp:ListItem Text=" 一個月內" Value="1" Selected="True"></asp:ListItem>
                    <asp:ListItem Text=" 三個月內" Value="3"></asp:ListItem>
                    <asp:ListItem Text=" 六個月內" Value="6"></asp:ListItem>
                    <asp:ListItem Text=" 不限" Value="0"></asp:ListItem>
                  </asp:RadioButtonList>
                </td>
              </tr>
            </table>
            <div class="selection-submit">
              <asp:LinkButton ID="lbtnSearch" runat="server" CssClass="btn" Text="確 定" OnClick="lbtnSearch_Click" />
            </div>
          </div>
          <!-- Page Nav User Control -->
          <Page:Nav ID="Nav1" runat="server"  OnOnPageSelected="Nav1_OnPageSelected"/>
          <div class="simple-list">
            <div class="track-table">
              <asp:GridView ID="gvOrderList" runat="server" AutoGenerateColumns="False" GridLines="None">
                <Columns>
                  <asp:BoundField DataField="" HeaderText="" HeaderStyle-CssClass="spacer">
                    <HeaderStyle CssClass="spacer"></HeaderStyle>
                  </asp:BoundField>
                  <asp:TemplateField HeaderText="訂單編號" ShowHeader="False">
                    <ItemTemplate>
                      <%--<asp:LinkButton ID="lbtnOrderID" runat="server" CausesValidation="false" CommandArgument='<%# Eval("ORDER_NO") %>' CommandName="OrderDetails" Text='<%# Eval("ORDER_NO") %>' OnClientClick="ggg(this);" ></asp:LinkButton>--%>
                      <a id='<%# Server.HtmlEncode(Eval("ORDER_NO").ToString()) %>' href="#" onclick="GetAccountOrderDetails(this.id,'');">
                        <%# Server.HtmlEncode(Eval("ORDER_NO").ToString()) %></a>
                    </ItemTemplate>
                  </asp:TemplateField>
                  <asp:BoundField DataField="ORDER_DATE" HeaderText="訂單日期" />                  
                  <asp:TemplateField HeaderText="訂單金額">                   
                    <ItemTemplate>
                      $ <asp:Label ID="lbl_TTL_AMT" runat="server" 
                        Text='<%# int.Parse(Server.HtmlEncode(Eval("TTL_AMT").ToString())).ToString("N0") %>'/>
                    </ItemTemplate>
                  </asp:TemplateField>
                  <asp:BoundField DataField="RCVR_Name" HeaderText="收件人" />
                  <asp:TemplateField HeaderText="訂單處理狀況">                   
                    <ItemTemplate>
                      <asp:Label ID="lbl_ORDER_STATUS" runat="server" 
                        Text='<%# CommonUtil.GetOrderStatus(Server.HtmlEncode(Eval("ORDER_STATUS").ToString())) %>'/>
                    </ItemTemplate>
                  </asp:TemplateField>
                  <asp:BoundField DataField="" HeaderText="" HeaderStyle-CssClass="spacer">
                    <HeaderStyle CssClass="spacer"></HeaderStyle>
                  </asp:BoundField>
                </Columns>
              </asp:GridView>
            </div>
          </div>
          <div class="liner t"></div>
          <!-- Page Nav User Control -->
          <Page:Nav ID="Nav2" runat="server"  OnOnPageSelected="Nav1_OnPageSelected"/>
        </div>
      </div>
      <div class="tab-content" id="ecoupon">
        <div class="simple-list">
          <h2>E-Coupon查詢</h2>
          <div class="track-message">
            <h2>您好，您有可使用的E-Coupon如下  </h2>
            <p class="orange-text">
              備註: E-Coupon不適用部分商品折扣
            </p>
          </div>
          <div class="track-table">
            <asp:GridView ID="gvECouponList" runat="server" AutoGenerateColumns="False" GridLines="None" BorderWidth="0">
              <Columns>
                <asp:BoundField DataField="" HeaderText="" HeaderStyle-CssClass="spacer" />
                <asp:BoundField DataField="DiscountNo" HeaderText="E-coupon 編號" />
                <asp:BoundField DataField="Price" HeaderText="E-coupon 金額" />
                <asp:BoundField DataField="RangeFrom" HeaderText="有效期限" />
                <asp:BoundField DataField="RangeTo" HeaderText="到期期限" />
                <asp:BoundField DataField="Memo" HeaderText="備註" />
                <asp:BoundField DataField="" HeaderText="" HeaderStyle-CssClass="spacer" />
              </Columns>
            </asp:GridView>
          </div>
        </div>
      </div>
      <div class="tab-content">
        <p></p>
      </div>
      <div class="tab-content" id="perInfo">
        <div class="lite-form">
          <table>
            <tr>
              <th>會員卡號</th>
              <td><asp:Label ID="lblCARD_ID" runat="server"></asp:Label></td>
            </tr>
            <tr>
              <th>會員姓名</th>
              <td><asp:Label ID="lblMemberName" runat="server"></asp:Label></td>
            </tr>
            <tr>
              <th>連絡電話</th>
              <td>
                  <asp:TextBox ID="tbTEL_HOME" runat="server"></asp:TextBox>
              </td>
            </tr>
            <tr>
              <th>行動電話</th>
              <td>
                <asp:TextBox ID="tbMOBILE" runat="server"></asp:TextBox>
              </td>
            </tr>
            <tr>
              <th>公司電話</th>
              <td>
                <asp:TextBox ID="tbTEL_OFFICE" runat="server"></asp:TextBox>
              </td>
            </tr>
            <tr>
              <th>傳真電話</th>
              <td>
                <asp:TextBox ID="tbFAX" runat="server"></asp:TextBox>
              </td>
            </tr>
            <tr>
              <th>E-mail</th>
              <td>
                  <asp:TextBox ID="tbEMAIL" runat="server"></asp:TextBox>
              </td>
            </tr>
            <tr>
              <th>通訊地址</th>
              <td>
                  <asp:DropDownList ID="ddlBuyerZone1" runat="server"></asp:DropDownList>
                  <asp:HiddenField ID="hfBuyerZone1" runat="server" />
                  <asp:DropDownList ID="ddlBuyerZone2" runat="server"></asp:DropDownList>
                  <asp:HiddenField ID="hfBuyerZone2" runat="server" />
                  <asp:TextBox ID="txtBuyerZIP" runat="server" CssClass="s"></asp:TextBox>
                  <asp:HiddenField ID="hfBuyerZIP" runat="server" />
                <%--<select>
                  <option value="value">縣市</option>
                </select>
                <select>
                  <option value="value">鄉鎮市</option>
                </select><asp:TextBox ID="tbZIP" class="s" runat="server"></asp:TextBox>--%>
              </td>
            </tr>
            <tr>
              <th></th>
              <td>
                  <asp:TextBox ID="txtBuyerAddress" runat="server" CssClass="l"></asp:TextBox>
                  <asp:Literal ID="ltlBuyerAddress" runat="server"></asp:Literal>
              </td>
            </tr>
          </table>
          <div class="notice">
            <h4>此處聯絡資料是商品發票寄送地址，修改這裡的資料並不會更動 <span class="orange-text">“無限萬哩遊”</span>的會員資料 。</h4>
          </div>
        </div>
        <div class="block ud t-a-r">
          <a href="#" onclick="UpdateMemberData();" class="btn">資料修改確定</a>
            <%--<asp:LinkButton ID="lbtnUpdateMemberData" runat="server"  class="btn" OnClick="lbtnUpdateMemberData_Click">資料修改確定1</asp:LinkButton>--%>
            <%--<asp:Button ID="btnUpdateMemberData" runat="server" Text="資料修改確定" class="btn" OnClick="btnUpdateMemberData_Click"/>--%>
        </div>
      </div>
    </div>
    <div class="tab-areas-detail myDivToPrint"" id="OrderDetails" style="display: none;">
      <div class="tab-content">
        <div class="block ud t-a-r">
          <a href="javascript:window.print();" class="print">列印訂購清單
          </a>
        </div>
        <div class="table-title">
          <table>
            <tr>
              <th colspan="3" class="red-text">訂單編號: 
                <asp:Label ID="lblORDER_NO" runat="server"></asp:Label></th>
            </tr>
            <tr>
              <th>訂購日期:
                <asp:Label ID="lblORDER_DATE" runat="server"></asp:Label></th>
              <th class="t-a-c">付款方式: 
                <asp:Label ID="lblPAY_TYPE" runat="server"></asp:Label></th>
              <th class="t-a-r">訂單狀況: 
                <asp:Label ID="lblORDER_STATUS" runat="server"></asp:Label></th>
            </tr>
          </table>
        </div>
        <div class="info-table intable">
          <table>
            <tbody>
              <tr class="title">
                <th colspan="4">收件人資料</th>
              </tr>
              <tr>
                <th>姓名</th>
                <td>
                  <asp:Label ID="lblRCVR_Name" runat="server"></asp:Label></td>
                <th>電話</th>
                <td>
                  <asp:Label ID="lblRCVR_TEL_H" runat="server"></asp:Label></td>
              </tr>
              <tr>
                <th>地址</th>
                <td>
                  <asp:Label ID="lblRCVR_ZIP_CODE_RCVR_ADDRESS" runat="server"></asp:Label></td>
                <th></th>
                <td></td>
              </tr>
              <tr class="title">
                <th colspan="4">購買者資料</th>
              </tr>
              <tr>
                <th>姓名</th>
                <td>
                  <asp:Label ID="lblCUST_NAME" runat="server"></asp:Label></td>
                <th>電話</th>
                <td>
                  <asp:Label ID="lblCUST_TEL_H" runat="server"></asp:Label></td>
              </tr>
              <tr>
                <th>地址</th>
                <td>
                  <asp:Label ID="lblCUST_ZIP_CODE_CUST_ADDRESS" runat="server"></asp:Label></td>
                <th class="longer">是否列印電子發票證明聯</th>
                <td>
                  <asp:Label ID="lblINVOICE_PRINT_IND" runat="server"></asp:Label></td>
              </tr>

            </tbody>
          </table>
        </div>
        <div class="list-table wish intable">
          <div class="JS_talbe">
            <div id="div1">
            </div>
            <div class="pink-result-all">
              <div class="mini-result">
                <table>
                  <tr>
                    <th>訂單小計(含稅)</th>
                    <td>
                      <asp:Label ID="lblSUB_TOTAL_SUM" runat="server"></asp:Label>元</td>
                  </tr>
                  <tr>
                    <th>折扣金額(含稅)</th>
                    <td>
                      <asp:Label ID="lblDISCOUNT_AMT" runat="server"></asp:Label>元</td>
                  </tr>
                  <tr>
                    <th>E-coupon金額</th>
                    <td>
                      <asp:Label ID="lblCOUPON_AMT" runat="server"></asp:Label>元</td>
                  </tr>
                  <tr>
                    <th>運費</th>
                    <td>
                      <asp:Label ID="lblFREIGHT_CHARAGE" runat="server"></asp:Label>元</td>
                  </tr>
                  <tr class="spaced">
                    <th>扣抵總哩程數</th>
                    <td>
                      <asp:Label ID="lblMILEAGE" runat="server"></asp:Label>哩</td>
                  </tr>
                  <tr class="red-text no-border">
                    <th>消費總計(含稅)</th>
                    <td>
                      <asp:Label ID="lblRCV_AMT" runat="server"></asp:Label>元</td>
                  </tr>
                </table>
              </div>
            </div>
          </div>
        </div>
      </div>      
    </div>
    <div class="go-to-top">
      <a href="#">回到頂端</a>
    </div>
  </div>
  <asp:HiddenField ID="HF_AuthType" runat="server" ClientIDMode="Static" />
  <asp:HiddenField ID="HF_UserID" runat="server" ClientIDMode="Static" />
</asp:Content>
